<?php
$_is_receive_modul=$_REQUEST['modal_dialog_mode'];
if(isset($_REQUEST['fuseaction_back'])) {
	$fuseaction_back=$_REQUEST['fuseaction_back'];
}else{
	$fuseaction_back = "";
}
if(isset($_REQUEST['hdn_worktype'])) {
	$v_worktype = $_REQUEST['hdn_worktype'];
}else{
	$v_worktype = "";
}
//echo $v_worktype;
//Luu giu dieu kien loc
$v_page=1;
if(isset($_REQUEST['hdn_page'])){
	$v_page=intval($_REQUEST['hdn_page']);
}
//Bien luu so dong tren mot trang
$v_limit_row = _CONST_NUMBER_OF_ROW_PER_LIST;
if(isset($_REQUEST['hdn_record_number_page'])){
	$v_limit_row = intval($_REQUEST['hdn_record_number_page']);
}
//$v_page = $_SESSION['v_session_page'];
//$v_limit_row = $_SESSION['v_session_limit_num_page'];
//echo 'v_page' . $v_page . '<br>';
//echo 'v_limit_row' . $v_limit_row . '<br>';
$v_list_xml_tag = "";
if(isset($_REQUEST['hdn_list_xml_tag'])){
	$v_list_xml_tag = $_REQUEST['hdn_list_xml_tag'];
}
$v_list_xml_value = "";
if(isset($_REQUEST['hdn_list_xml_value'])){
	$v_list_xml_value = $_REQUEST['hdn_list_xml_value'];
}
$v_relate_record_code = "";
if(isset($_REQUEST['hdn_relate_record_code'])){
	$v_relate_record_code = _replace_bad_char($_REQUEST['hdn_relate_record_code']);
}
//echo 'v_relate_record_code'.$v_relate_record_code.'<br><br>';
$v_staff_id = $_SESSION['staff_id'];
//Lay du lieu tu database
//echo $v_record_id;

if ($v_record_id>0){
	$v_recordtype_record = $arr_single_record['FK_RECORDTYPE'];
	//$v_code_record = $arr_single_record['C_CODE'];
	//$v_current_status = $arr_single_record['C_CURRENT_STATUS'];
	$v_detail_status = $arr_single_record['C_CURRENT_STATUS'];
	//$v_received_date = _yyyymmdd_to_ddmmyyyy($arr_single_record['C_RECEIVED_DATE']);
	//$v_appointed_date = _yyyymmdd_to_ddmmyyyy($arr_single_record['C_APPOINTED_DATE']);
	$v_xml_str = $arr_single_record['C_RECORD_XML_DATA'];
}else{
	if (_CONST_AUTOMATIC_RECORD_CODE_GENERATE){
		$v_code_record = onegate_generate_record_code($v_recordtype_filter);
	}else{
		$v_code_record = "";
	}
	$v_current_status = "";
	$v_detail_status = "";
	$v_received_date = date("d/m/Y");
	$v_appointed_date = "";
	$v_xml_str = '<?xml version="1.0" encoding="UTF-8"?><root><data_list></data_list></root>';
}

//echo 'v_record_form'.$v_record_form.'<br>';
//echo 'v_recordtype_filter'.$v_recordtype_filter.'<br>';
//echo 'onegate_get_handle_agency_id'.onegate_get_handle_agency_id($_SESSION['recordtype'],$v_recordtype_filter).'<br>';
//echo $v_relate_record_code ;
//echo $v_recordtype_filter;
//$v_relate_recordtype= $v_recordtype_filter;  //PHUCDD

//Kiem tra xem co phai lay noi dung don tu ho so lien quan
if ($v_relate_record_code != ""){
	$arr_single_record_by_code = Query_Data_For_Colunm_name("Select * From T_ONEGATE_RECORD Where C_CODE ='$v_relate_record_code'");
	$v_xml_str = $arr_single_record_by_code[0]['C_RECEIVED_RECORD_XML_DATA'];
	//$v_xml_licences_str = $arr_single_record_by_code[0]['C_LICENSE_XML_DATA'];
	//	var_dump($arr_single_record_by_code);
	//echo htmlspecialchars($v_xml_str);// exit;
	//chi nhung ho so phong KD thi moi thuc hien doan nay
	//if ((onegate_get_handle_agency_id($_SESSION['recordtype'],$v_recordtype_filter) == '215')&& ($v_worktype == 'TIEP_NHAN')){
	//Thuc hien lay ma so dkkd va so lan thuc hien cua ho so
	if ((($v_recordtype_filter == '001') || ($v_recordtype_filter == '002') || ($v_recordtype_filter == '011') || ($v_recordtype_filter == '012') || ($v_recordtype_filter == '013') || ($v_recordtype_filter == '041') || ($v_recordtype_filter == '014') || ($v_recordtype_filter == '045') || ($v_recordtype_filter == '037') || ($v_recordtype_filter == '034') || ($v_recordtype_filter == '048')) && ($v_worktype == 'TIEP_NHAN')){
		if(isset($_REQUEST['record_form'])) {
			$v_record_form = $_REQUEST['record_form'];
		}

		$v_xml_str = $arr_single_record_by_code[0]['C_LICENSE_XML_DATA'];
		//echo htmlspecialchars($v_xml_str);// exit;
		$v_record_license = _XML_get_xml_tag_value($v_xml_str,'record_number');
		//echo $v_record_license; exit;
		$v_str_sql = "Select Count(*) As SO_LAN From T_ONEGATE_RECORD Where FK_RECORDTYPE ='".$v_recordtype_filter."'";
		$v_str_sql = $v_str_sql." And C_CURRENT_STATUS = 'CAP_PHEP' And dbo.f_GetValueOfXMLtag(C_RECEIVED_RECORD_XML_DATA, 'record_form') = '".$v_record_form."'";
		$v_str_sql = $v_str_sql." And dbo.f_GetValueOfXMLtag(C_LICENSE_XML_DATA, 'record_number') = '".$v_record_license."'";
		//echo 'v_str_sql'.$v_str_sql;
		$v_arr = Query_Data_For_Colunm_name($v_str_sql);
		$v_record_quanlity = $v_arr[0]['SO_LAN'] + 1;

		# Updated by Dinh, Nguyen - 30062007
		# Content: Capture & fix the error when get content of lisence
		if (is_null($v_xml_str) || $v_xml_str=="") {
			$v_xml_str = '<?xml version="1.0" encoding="UTF-8"?><root><data_list></data_list></root>';
		}
		# End Dinh, Nguyen		

		if (strpos($v_xml_str, 'record_form')) {
			$v_xml_str = _replace_xml_tag_value($v_xml_str,'record_form',$v_record_form);
		}else{
			$v_xml_str = _insert_xml_tag_and_value($v_xml_str,'record_form',$v_record_form);
		}
		if (strpos($v_xml_str, 'record_number')) {
			//echo $v_record_license;
			$v_xml_str = _replace_xml_tag_value($v_xml_str,'record_number',$v_record_license);
		}else{
			$v_xml_str = _insert_xml_tag_and_value($v_xml_str,'record_number',$v_record_license);
		}
		if (strpos($v_xml_str, 'record_quanlity')) {
			$v_xml_str = _replace_xml_tag_value($v_xml_str,'record_quanlity',$v_record_quanlity);
		}else{
			$v_xml_str = _insert_xml_tag_and_value($v_xml_str,'record_quanlity',$v_record_quanlity);
		}
	}
	
	//Phan dau cua dinh dang xau xml
	$v_xml_str_header = '<?xml version="1.0" encoding="UTF-8"?><root><data_list>';
	//Cong them gia tri cua xau chua so giay phep vao
	$v_xml_replace = $v_xml_str_header . '<relate_record>' . $v_relate_record_code .'</relate_record>';
	
	if (is_null($v_xml_str) || $v_xml_str==""){
		$v_xml_str = $v_xml_replace . '</data_list></root>';	
	}else{
		$v_xml_str = str_replace($v_xml_str_header,$v_xml_replace,$v_xml_str);
	}
}

//echo htmlspecialchars($v_xml_str);//exit;
$v_readonly = "";
if (_CONST_AUTOMATIC_RECORD_CODE_GENERATE){
	$v_readonly = "readonly";
}
//Duong dan den hop hien thi lich
$v_url_path_calendar = '"'.$_ISA_LIB_URL_PATH.'isa-calendar/"';
//So ngay xu ly doi voi moi loai ho so
$v_process_date = 0;
for ($i=0;$i < sizeof($_SESSION['recordtype']);$i++){
	if ($_SESSION['recordtype'][$i]['PK_RECORDTYPE']==$v_recordtype_filter){
		$v_process_date = $_SESSION['recordtype'][$i]['C_PROCESS_DATE'];
		break;
	}
}
$v_current_year = date("Y");
//cac file chua cau truc cua bang
$v_table_struct_xml_file = "../../xml/".$v_recordtype_filter."/cau_truc_bang_don_xin_cap_phep.xml";
$v_formfield_xml_file = "../../xml/".$v_recordtype_filter."/cac_dong_cua_don_xin_cap_phep.xml";
if (file_exists($v_table_struct_xml_file) && file_exists($v_table_struct_xml_file)){
	$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
	$v_formfield_xml_string = _read_file($v_formfield_xml_file);
}else{
	$v_table_struct_xml_file = "../../xml/other/cau_truc_bang_don_xin_cap_phep.xml";
	$v_formfield_xml_file = "../../xml/other/cac_dong_cua_don_xin_cap_phep.xml";
	$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
	$v_formfield_xml_string = _read_file($v_formfield_xml_file);
}
//Cho hien don them mot ho so tranh chap _NgocNTM
if($fuseaction=="DISPLAY_SINGLE_RECORD_DISPUTE")
{
	$v_table_struct_xml_file="../../xml/All/cau_truc_ho_so_tranh_chap.xml";
	$v_formfield_xml_file = "../../xml/All/cac_dong_ho_so_tranh_chap.xml";
	$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
	$v_formfield_xml_string = _read_file($v_formfield_xml_file);
}
//******************End _NgocNTM
$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
$v_formfield_xml_string = _read_file($v_formfield_xml_file);
//Doc va ghi ra tieu de cua form
$table_struct_rax = new RAX(); 
$table_struct_rec = new RAX(); 
$table_struct_rax->open($v_table_struct_xml_string);
$table_struct_rax->record_delim = 'common_para';
$table_struct_rax->parse();
$table_struct_rec = $table_struct_rax->readRecord(); 
$table_struct_row = $table_struct_rec->getRow();
$v_form_title = $table_struct_row["form_title"];
$v_first_col_width = $table_struct_row["first_col_width"];
$v_second_col_width = (100-$v_first_col_width)."%";
$v_js_file_name = $table_struct_row["js_file_name"];
$v_js_function  = $table_struct_row["js_function"];
if (!is_null($v_title)&&($v_title!="")){
	$v_form_title = $v_title;
}
///Begin//Form
$v_html_string = '<script src="../js-record/'.$v_js_file_name.'"></script>';
//Begin//Bang chua cac thanh phan cua form
$v_html_string = $v_html_string . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr>";
$v_html_string = $v_html_string . "<td class='large_title'>".$v_form_title."</td>";
$v_html_string = $v_html_string . "</tr></table>";
//Bang chua cac bin hidden
$v_html_string = $v_html_string . "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";
$v_html_string = $v_html_string . "<form action='index.php' method='post' name='f_dsp_single_record' enctype='multipart/form-data'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_list_xml_tag' value=''>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_list_xml_value' value=''>";
$v_html_string = $v_html_string . "<input type='hidden' name='fuseaction' value=''>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_received_date' value='".date("d/m/Y")."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_record_id' value='".$v_record_id ."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_recordtype_filter' value='".$v_recordtype_filter ."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_received_date_filter' value='".$v_receive_date_filter ."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='fuseaction_back' value='".$fuseaction_back."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_worktype' value='".$v_worktype."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_page' value='".$v_page."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_record_number_page' value='".$v_limit_row."'>";
//Luu ID cua cac file da co nhung da bi xoa
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_deleted_exist_file_id_list' value=''>";
//Luu ID cua cac file moi them nhung da bi xoa
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_deleted_new_file_id_list' value=''>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_doc_another' value=''>";
$v_html_string = $v_html_string . "</td></tr></table>";
//Doc cac dong cua form	
$table_struct_rax = new RAX(); 
$table_struct_rec = new RAX(); 
$table_struct_rax->open($v_table_struct_xml_string);
$table_struct_rax->record_delim = 'row';
$table_struct_rax->parse();
$table_struct_rec = $table_struct_rax->readRecord(); 
//Bang chua cac dong cua form
$v_html_string = $v_html_string . "<table width='100%' class='form_table1'  border='0' cellspacing='0' cellpadding='0'><tr><td>";
///Begin///Bang chua cac dong co dinh cua ho so
$v_html_string = $v_html_string . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>";
$v_html_string = $v_html_string . "<col width='21%'><col width='29%'><col width='20%'><col width='30%'>";
//$v_html_string = $v_html_string . "<tr><td class='normal_label' align='left'>".CONST_RECORD_TYPE_LABEL."</td>";
//$v_html_string = $v_html_string . "<td colspan='3'><select class='normal_selectbox' name='sel_recordtype' disabled optional='true' style='width:100%'>";
//$v_html_string = $v_html_string . _generate_select_option($_SESSION['recordtype'],'PK_RECORDTYPE','PK_RECORDTYPE','C_NAME', $v_recordtype_filter);
//$v_code_record=$v_id_conflict;
//echo '.....'.gettype
$v_html_string = $v_html_string . "</select></td></tr>";
/*$v_html_string = $v_html_string . "<tr><td class='normal_label'>".CONST_RECORD_CODE_LABEL."<small class='normal_starmark'>*</small></td><td><input type='text' name='txt_code_record' class='normal_textbox' $v_readonly style='width:93%' value='$v_id_conflict' optional='' message = '".CONST_RECORD_CODE_MESSAGE."' onKeyDown='change_focus(document.forms(0),this)'></td></tr>";*/
$v_html_string = $v_html_string . "<tr><td class='normal_label'>".'Ng&agrave;y nh&#7853;p h&#7891; s&#417;'."<small class='normal_starmark'>*</small></td><td><input type='text' name='txt_received_date' class='normal_textbox' style='width:93%' value='$v_date_conflict' optional='' message = '".CONST_RECORD_RECEIVED_DATE_MESSAGE."' isdate='true' onChange='get_appoint_date(document.forms(0).txt_received_date,$v_process_date,document.forms(0).txt_appointed_date,$v_current_year);' onKeyDown='change_focus(document.forms(0),this)' readonly></td>";
/*$v_html_string = $v_html_string . "<img src='". $_ISA_IMAGE_URL_PATH."calendar.gif' border='0' onclick='DoCal($v_url_path_calendar,document.forms(0).txt_received_date);get_appoint_date(document.forms(0).txt_received_date,$v_process_date,document.forms(0).txt_appointed_date,$v_current_year);' style='cursor:hand'></td>";*/
/*$v_html_string = $v_html_string . "<td class='normal_label'>".CONST_RECORD_APPOINTED_DATE_LABEL."</td><td><input type='text' name='txt_appointed_date' class='normal_textbox' style='width:85%' value='$v_appointed_date' optional='true' message = '".CONST_RECORD_APPOINTED_DATE_MESSAGE."' isdate='true' onKeyDown='change_focus(document.forms(0),this)'>";
$v_html_string = $v_html_string . "<img src='". $_ISA_IMAGE_URL_PATH."calendar.gif' border='0' onclick='DoCal($v_url_path_calendar,document.forms(0).txt_appointed_date);' style='cursor:hand'></td></tr>";*/
/*$v_html_string = $v_html_string . "<tr><td class='normal_label' align='left'>".CONST_RECORD_CURRENT_STATUS_LABEL."</td>";
$v_html_string = $v_html_string . "<td colspan='3'><select class='normal_selectbox' name='sel_recordtype' disabled optional='true' style='width:100%'>";
$v_html_string = $v_html_string . _generate_select_option($arr_record_status,'0','0','1', $v_current_status);*/
$v_html_string = $v_html_string . "</select></td></tr>";
$v_html_string = $v_html_string . "</table>";
///End///Bang chua cac dong co dinh cua ho so
//echo $v_html_string;exit;
//echo htmlspecialchars($v_xml_str); exit;
while ($table_struct_rec) { 
	$table_struct_row = $table_struct_rec->getRow();
	$v_have_line_before = $table_struct_row["have_line_before"];
	$v_col_number = $table_struct_row["col_number"];
	$v_tag_list = $table_struct_row["tag_list"];
	$v_row_id = $table_struct_row["row_id"];
	$arr_tag = explode(",", $v_tag_list);
	if ($v_have_line_before=="true"){
		$v_html_string = $v_html_string . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr id = '$v_row_id'>";
		$v_html_string = $v_html_string . "<td><hr width='100%' color='#66CCFF' size='1'></td>";
		$v_html_string = $v_html_string . "</tr></table>";
	}
	//Bang chua mot dong cua form
	$v_html_string = $v_html_string . "<table width='100%'  border='0' cellspacing='0' cellpadding='0' >";
	$v_html_table = "";
	$v_html_tag = "";			
	for($i=0;$i < sizeof($arr_tag);$i++){
		$formfield_rax = new RAX(); 
		$formfield_rec = new RAX(); 
		$formfield_rax->open($v_formfield_xml_string);
		$formfield_rax->record_delim = $arr_tag[$i];
		$formfield_rax->parse();
		$formfield_rec = $formfield_rax->readRecord(); 
		$formfield_row = $formfield_rec->getRow(); 
		$v_label = $formfield_row["label"];
		$v_type = $formfield_row["type"];
		$v_dataformat = $formfield_row["data_format"];
		$v_width = $formfield_row["width"];
		$v_row = $formfield_row["row"];
		$v_max = $formfield_row["max"];
		$v_min = $formfield_row["min"];
		$v_note = $formfield_row["note"];
		$v_tooltip = $formfield_row["tooltip"];
		$v_message = $formfield_row["message"];
		$v_optional = $formfield_row["optional"];
		$v_maxlength = $formfield_row["maxlength"];
		$v_status_dsp = $formfield_row["dsp_status"];
		$v_xml_tag_in_db = $formfield_row["xml_tag_in_db"];				
		//echo $v_label."<br>";
		$v_default_value = $formfield_row["default_value"];
		$v_js_function_list = $formfield_row["js_function_list"];
		$v_js_action_list = $formfield_row["js_action_list"];
		$v_relate_recordtype = $formfield_row["relate_recordtype"]; 
		//$v_relate_recordtype = $v_recordtype_filter; //phucdd   thay the bang bien nay no se thay doi theo ma ho so la ok roi
		$v_readonly_in_edit_mode = $formfield_row["readonly_in_edit_mode"];
		$v_disabled_in_edit_mode = $formfield_row["disabled_in_edit_mode"];
		if ($v_xml_str!=""){
			$column_rax = new RAX(); 
			$column_rec = new RAX();
			$column_rax->open($v_xml_str);
			$column_rax->record_delim = 'data_list';
			$column_rax->parse();
			$column_rec = $column_rax->readRecord(); 
			$column_row = $column_rec->getRow();
			$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]); 
		}
		//Kiem tra neu gia tri DEFAULT  ton tai va gia tri cua truong do la bang rong thi thay the bang gia tri Default
		if ((!is_null($v_default_value) && $v_default_value!="")&&(is_null($v_value) || $v_value=="")){
			$v_value = $v_default_value;
		}
		//Kiem tra neu gia tri cua truong do la bang rong thi cho phep nhap du lieu
		if (is_null($v_value) || $v_value==""){
			$v_readonly_in_edit_mode = "false";
			$v_disabled_in_edit_mode = "false";
		}
		
		if ($v_type=="selectbox"){
			$v_selectbox_option_sql = $formfield_row["selectbox_option_sql"];
			$v_selectbox_id_column = $formfield_row["selectbox_option_id_column"];
			$v_selectbox_name_column = $formfield_row["selectbox_option_name_column"];
			
			if($v_xml_tag_in_db == "record_form"&&isset($_REQUEST['record_form'])){
				$v_value = $_REQUEST['record_form'];
			}
		}
		if ($v_type=="checkboxmultiple"){
			$v_checkbox_multiple_sql = $formfield_row["checkbox_multiple_sql"];
			$v_checkbox_multiple_id_column = $formfield_row["checkbox_multiple_id_column"];
			$v_checkbox_multiple_name_column = $formfield_row["checkbox_multiple_name_column"];
		}
		$v_html_table = $v_html_table . "<col width='$v_first_col_width'>" . "<col width='$v_second_col_width'>";		
		$v_html_tag = $v_html_tag . Generate_HTML_Input();		
	}
	$v_html_string = $v_html_string .  $v_html_table . "<tr id = '$v_row_id' style='display:block'>" . "<td class='normal_label'>" . $v_html_tag."</td>";
	$v_html_string = $v_html_string . "</tr></table>";
	$table_struct_rec = $table_struct_rax->readRecord();
}
$v_html_string = $v_html_string . "</td></tr>";
$v_html_string = $v_html_string . "</table>";
$v_html_string = $v_html_string . '<script language="JavaScript">'.$v_js_function.'</script>';
//End//Bang chua cac thanh phan cua form
echo $v_html_string; 
?>
<table width='100%'  border='0' cellspacing='0' cellpadding='0'>
	<tr height="10px"><td>&nbsp;</td></tr>
	<tr align="center">
		<td><?php
		if ((($v_is_granted_update)||onegate_is_receiver_for_recordtype($v_staff_id,$v_recordtype_filter,$_SESSION["recordtype"]))&&($v_current_status<>"DANG_THU_LY")&&($v_current_status!="CAP_PHEP")||(($v_current_status=="DANG_THU_LY")&&($v_detail_status == 20))){?>
		<?php
		}
		//echo "kkk";
//*************************NgocNTM******************************//
//1858 ma cua admin
//Them nut cap nhat cho ho so tranh chap __NgocNTM		
		if(($v_record_id =="" && $v_staff_id!='1858')||$v_staff_id =='2308') { 
		
		//Neu la them lan dau tien thi cho cap nhat ?> 
		<input type='button' class='normal_button' name="btn_update_NgocNTM" value='<?php echo _CONST_SAVE_BUTTON;?>' onClick="check_value_in_form();save_hidden_multiple_list(document.forms(0).chk_item_id,',');save_list_onclick(document.forms(0),document.forms(0).hdn_list_xml_tag,document.forms(0).hdn_list_xml_value);test_status_show_hide_record_ngocNTM();" onKeyDown="change_focus(document.forms(0),this)">&nbsp;
	
	<?php  }
	else {//hien thi nut cap nhat neu la can bo nhap ho so nguoc lai thi ko cho cap nhat
		if (($_IS_APPROVING ||(($v_staff_id == $arr_single_record["FK_USER"])&&$v_record_id !=""))&& $_is_receive_modul<>1){?> 
			<input type='button' class='normal_button' name="btn_update_NgocNTM" value='<?php echo _CONST_SAVE_BUTTON;?>' onClick="check_value_in_form();save_hidden_multiple_list(document.forms(0).chk_item_id,',');save_list_onclick(document.forms(0),document.forms(0).hdn_list_xml_tag,document.forms(0).hdn_list_xml_value);test_status_show_hide_record_ngocNTM();" onKeyDown="change_focus(document.forms(0),this)">&nbsp;
	<?php }
	}?>&nbsp;
			<input type="button" value="<?php echo _CONST_BACK_BUTTON; ?>" name="btn_add" class="normal_button" onClick="btn_back_onclick('<?php echo $_GO_BACK?>')">
		</td>	
	</tr>
</table>
<!--//End//Form-->
</form>
<script language="JavaScript">
	if(test_tag("status_record")){
		//Neu dang trang thai la thieu HS thi khong cho tinh ngay tu dong tra ket qua cho cong dan nua.
		if(!document.forms(0).status_record.checked){
			get_appointed_date();
			show_hide_record();
		}else{
			get_appointed_date();
		}	
	}else{
		get_appointed_date();
	}
	//kiem tra co ton tai the de luu noi dung cua tai lieu khac o muc nhap tai lieu kem theo khong?
	//Neu ton tai thi an gia the nay di
	if(test_tag("doc_another")){
		//var v_value_from_tab = get_value_from_tag("doc_another");
		//alert(v_value_from_tab);
		show_hide_content_doc_another();
		var v_value_from_tab = get_value_from_tag("doc_another");
		//alert(v_value_from_tab);
		if((v_value_from_tab == "") && (isblank(v_value_from_tab))){
			hide_row('doc_another');
		}	
	}		
	set_focus(document.forms(0));	
	function get_appointed_date(){
		<?php if ($v_record_id<=0){?>
			get_appoint_date(document.forms(0).txt_received_date,<?php echo $v_process_date;?>,document.forms(0).txt_appointed_date,<?php echo $v_current_year;?>);<?php
		}elseif ($v_worktype=="NHAN_HO_SO_BO_SUNG"){?>
			get_appoint_date(document.forms(0).hdn_received_date,<?php echo $v_process_date;?>,document.forms(0).txt_appointed_date,<?php echo $v_current_year;?>);<?php
		}?>					
	}
</script>